import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDLegionPosition {
	/**职位ID*/
	id,
	/**职位名称*/
	name,
	/**描述*/
	desc,
	/**通过入会邀请（1：可以通过入会邀请；0：无操作权限）*/
	passMember,
	/**踢出会员(1:可以踢出职位ID为4的会员；0：无踢人权限）*/
	kickMember,
	/**踢出官员(1:可以踢出职位ID大于自己的会员；0：无踢人权限）*/
	kickOfficer,
	/**修改公告(1:可以修改公告；0：不可以修改公告）*/
	mark,
	/**职位数量(0:无限制，不超过公会人数限制；＞0，按数值）*/
	positionNum,

	/**枚举数量*/
	EnumCount
}



export class CDLegionPosition{
	/**职位ID*/
	public id: number;
	/**职位名称*/
	public name: number;
	/**描述*/
	public desc: number;
	/**通过入会邀请（1：可以通过入会邀请；0：无操作权限）*/
	public passMember: number;
	/**踢出会员(1:可以踢出职位ID为4的会员；0：无踢人权限）*/
	public kickMember: number;
	/**踢出官员(1:可以踢出职位ID大于自己的会员；0：无踢人权限）*/
	public kickOfficer: number;
	/**修改公告(1:可以修改公告；0：不可以修改公告）*/
	public mark: number;
	/**职位数量(0:无限制，不超过公会人数限制；＞0，按数值）*/
	public positionNum: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDLegionPosition.id: return this.id;
			case E_CDLegionPosition.name: return this.name;
			case E_CDLegionPosition.desc: return this.desc;
			case E_CDLegionPosition.passMember: return this.passMember;
			case E_CDLegionPosition.kickMember: return this.kickMember;
			case E_CDLegionPosition.kickOfficer: return this.kickOfficer;
			case E_CDLegionPosition.mark: return this.mark;
			case E_CDLegionPosition.positionNum: return this.positionNum;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDLegionPosition.id: this.id = v; break;
			case E_CDLegionPosition.name: this.name = v; break;
			case E_CDLegionPosition.desc: this.desc = v; break;
			case E_CDLegionPosition.passMember: this.passMember = v; break;
			case E_CDLegionPosition.kickMember: this.kickMember = v; break;
			case E_CDLegionPosition.kickOfficer: this.kickOfficer = v; break;
			case E_CDLegionPosition.mark: this.mark = v; break;
			case E_CDLegionPosition.positionNum: this.positionNum = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDLegionPosition> = new HashMap<number, CDLegionPosition>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDLegionPosition[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDLegionPosition();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].passMember = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].kickMember = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].kickOfficer = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].mark = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].positionNum = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDLegionPosition{
		return this.datas ? this.datas.get(id) : null;
	}
}
